{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1690e5b8",
   "metadata": {},
   "source": [
    "# 回顾上周内容:\n",
    "## 1.认识列表:[value1,value2,.....]\n",
    "## 2.列表的查询\n",
    ">1.索引值进行查询(单个值):index\n",
    ">2.切片进行查询(多值):slice\n",
    "## 3.列表的一般方法\n",
    ">1.增加元素\n",
    ">2.删除元素\n",
    ">3.修改内容\n",
    ">4.查询内容\n",
    "\n",
    "|  方法  | 格式 |   结果   |\n",
    "| :----- | :--: | -------: |\n",
    "| 增 |  append(\"\")  | 增加数据，增加在末尾......append(object) |\n",
    "| 增 | insert(1,\"Dan\")|insert指定位置增加数据......         insert(index)|\n",
    "| 减 |  remove(\"\")  | 按照值,指定某个数据进行删除......         remove(value)  |\n",
    "| 减 |  pop()  | pop(index=-1, /)默认删除最后一个的值,如果加上指定位置，names.pop(1)<==> del names[1] ......        pop(index)|\n",
    "|clear()|List.clear()|remove all items from L|\n",
    "|count()|List.count(value)|查询某个value出现的次数（共现的次数），通常用在计算词频、统计操作当中|\n",
    "|extend() 扩展| L.extend(iterable)|iterable 将拼接在 L 的后面（末尾）|\n",
    "|copy()复制|B = A.copy()|复制|\n",
    "|切片[:](实现真正意义的复制)|B = A[:]|复制|\n",
    "|sort()|reverse=False (默认从小到大)   可修改 reverse = True (从大到小)|排列顺序|"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f36cada7",
   "metadata": {},
   "source": [
    "# 2.本周内容\n",
    "\n",
    "## 2.1列表的其他方法\n",
    "\n",
    "## 2.2列表的实践(课内)\n",
    "\n",
    "## 2.3列表的实践(课外)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "d3e2287b",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = [\"Mike\",\"Mary\",\"Jan\",\"Jack\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "d4f55b8e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'Mary', 'Jan', 'Jack']"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "617a26a2",
   "metadata": {},
   "source": [
    ">clear"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "58be5233",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function clear:\n",
      "\n",
      "clear() method of builtins.list instance\n",
      "    Remove all items from list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.clear)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "93f36a8b",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.clear()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "18231def",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8489c11b",
   "metadata": {},
   "source": [
    ">.count()\n",
    ">> 1 .使用方法:L.count(value)\n",
    "\n",
    ">> 2 .结果:查询某个value出现的次数,通常用在计算词频."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "8f57b81c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function count:\n",
      "\n",
      "count(value, /) method of builtins.list instance\n",
      "    Return number of occurrences of value.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(分数_list.count)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "36cf7c83",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[88, 89, 68, 78, 88, 90, 93, 88]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "分数_list = [88,89,68,78,88,90,93,88]\n",
    "分数_list"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "86d839d3",
   "metadata": {},
   "source": [
    "> extend() 扩展\n",
    ">> 1.使用方法:L.extend(iterable)\n",
    "\n",
    ">> 2.结果: iterable 将拼接在 L 的后面"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "a9e098b4",
   "metadata": {},
   "outputs": [],
   "source": [
    "分数_list_树莓技术1班 = [88,89,68,78,88,90,93,88]\n",
    "分数_list_树莓技术2班 = [88,78,76,88,89,66]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "bcf46c1c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function extend:\n",
      "\n",
      "extend(iterable, /) method of builtins.list instance\n",
      "    Extend list by appending elements from the iterable.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(分数_list.extend)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "06c796fa",
   "metadata": {},
   "outputs": [],
   "source": [
    "分数_list_树莓技术1班.extend(分数_list_树莓技术2班)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "1789905a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[88, 89, 68, 78, 88, 90, 93, 88, 88, 78, 76, 88, 89, 66]"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "分数_list_树莓技术1班"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "b8c024f1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[88, 89, 68, 78, 88, 90, 93, 88, 88, 78, 76, 88, 89, 66]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 等价于\n",
    "[88,89,68,78,88,90,93,88]+[88,78,76,88,89,66]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2199642f",
   "metadata": {},
   "source": [
    "> 4.<font style = \"color=red\">copy()\n",
    ">>1.在列表中'赋值' 不等价于 '复制'\n",
    ">>2.真正意义的复制列表的两种常见方法\n",
    ">>> 1. copy()\n",
    ">>> 2. 切片[;]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "74a3d9e7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "jack alex\n",
      "1888254638768 1888254637296\n"
     ]
    }
   ],
   "source": [
    "name1 = \"alex\"\n",
    "name2 = name1\n",
    "name1 = \"jack\"\n",
    "print(name1,name2)\n",
    "print(id(name1),id(name2))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "37be0cf6",
   "metadata": {},
   "outputs": [],
   "source": [
    "#此案例 来源: 课本p72页:看起来像复制,但其实不是\n",
    "first = [1,2,3,4,5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "8591f440",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "first"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "f0e3588f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1888237853952\n"
     ]
    }
   ],
   "source": [
    "print(id(first))# first 的数据地址:1888237853952"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "88fac55e",
   "metadata": {},
   "outputs": [],
   "source": [
    "second = first"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "75f71d50",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1888237853952\n"
     ]
    }
   ],
   "source": [
    "print(id(second))#second 的数据地址:1888237853952"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "83196899",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5]"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "second"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "d0d8ca73",
   "metadata": {},
   "outputs": [],
   "source": [
    "first.append(6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "1ab4f5cc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6]\n"
     ]
    }
   ],
   "source": [
    "print(first,second)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "97649b0d",
   "metadata": {},
   "source": [
    "* 结论是:赋值有两种情况:\n",
    "\n",
    "> 1. 赋值的数据类型 是不可变的数据 (字符串;数值;元组),分配不同的数据地址\n",
    "> 2. 赋值的数据类型是可变的数据(列表)分配同一个地址,指向同一个列表"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "845719ce",
   "metadata": {},
   "source": [
    "###  列表的复制方法一"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "12f1153b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4, 5] [1, 2, 3, 4, 5]\n",
      "1888251132224 1888251150272\n"
     ]
    }
   ],
   "source": [
    "first = [1,2,3,4,5]\n",
    "second = first.copy()\n",
    "print(first,second)\n",
    "print(id(first),id(second))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "558b3817",
   "metadata": {},
   "outputs": [],
   "source": [
    "first.append(6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "65332049",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5]\n"
     ]
    }
   ],
   "source": [
    "print(first,second)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5555f907",
   "metadata": {},
   "source": [
    "### 列表的复制方法二\n",
    "* 切片[:] 可以实现真正意义的复制"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "5c5a23df",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4, 5] [1, 2, 3, 4, 5]\n",
      "1888255588288 1888255589248\n"
     ]
    }
   ],
   "source": [
    "first = [1,2,3,4,5]\n",
    "second = first[:] \n",
    "\n",
    "print(first,second)\n",
    "print(id(first),id(second))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bce75a46",
   "metadata": {},
   "source": [
    "### 思考 copy() 只复制 第一层"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "e690e322",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, [4, 5, 6]] [1, 2, 3, [4, 5, 6]]\n",
      "1888255625472 1888256470336\n"
     ]
    }
   ],
   "source": [
    "first = [1,2,3,[4,5,6]]\n",
    "second = first.copy()\n",
    "\n",
    "print(first,second)\n",
    "print(id(first),id(second))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "49ef9659",
   "metadata": {},
   "outputs": [],
   "source": [
    "first[3].append(7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "9d058cb0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, [4, 5, 6, 7]]"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "first"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "f53432af",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, [4, 5, 6, 7]]"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "second"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1ee49755",
   "metadata": {},
   "source": [
    "> 6.排序:sort()\n",
    ">> 1. reverse=False (默认从小到大)\n",
    ">> 2. 可修改reverse=ture(从大到小)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "62801e8d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sort:\n",
      "\n",
      "sort(*, key=None, reverse=False) method of builtins.list instance\n",
      "    Sort the list in ascending order and return None.\n",
      "    \n",
      "    The sort is in-place (i.e. the list itself is modified) and stable (i.e. the\n",
      "    order of two equal elements is maintained).\n",
      "    \n",
      "    If a key function is given, apply it once to each list item and sort them,\n",
      "    ascending or descending, according to their function values.\n",
      "    \n",
      "    The reverse flag can be set to sort in descending order.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(分数_list_树莓技术1班.sort)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "3a0d5b5c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[88, 89, 68, 78, 88, 90, 93, 88, 88, 78, 76, 88, 89, 66]"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "分数_list_树莓技术1班"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "c2d2ad40",
   "metadata": {},
   "outputs": [],
   "source": [
    "分数_list_树莓技术1班.sort()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "082c61f2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[66, 68, 76, 78, 78, 88, 88, 88, 88, 88, 89, 89, 90, 93]"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "分数_list_树莓技术1班"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9fb1eae1",
   "metadata": {},
   "source": [
    "## 2.2列表的实践(课内)     一"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "720bf323",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n",
      "['o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n",
      "['o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c']\n",
      "['o', 'n', 't', ' ', 'p', 'a', 'n', 'i', 'c']\n",
      "['o', 'n', 't', ' ', 'c', 'p', 'a', 'n', 'i']\n",
      "['o', 'n', ' ', 't', 'c', 'p', 'a', 'n', 'i']\n",
      "on tcpani\n",
      "['o', 'n', ' ', 't', 'c', 'p', 'a', 'n']\n",
      "['o', 'n', 't', 'c', 'p', 'a', 'n']\n",
      "['o', 'n', 't', 'c', 'n', 'p', 'a']\n",
      "['o', 'n', 'c', 't', 'n', 'p', 'a']\n",
      "onctnpa\n",
      "['o', 'n', 'c', 't', 'n', 'p']\n",
      "['o', 'n', 't', 'n', 'p']\n",
      "['o', 'n', 't', 'n', 'p']\n",
      "['o', 'n', 'n', 't', 'p']\n",
      "onntp\n",
      "['o', 'n', 'n', 't']\n",
      "['o', 'n', 't']\n",
      "['o', 'n', 't']\n"
     ]
    },
    {
     "ename": "IndexError",
     "evalue": "pop index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-104-15ffa1c3ff1b>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m     20\u001b[0m     \u001b[0mplist\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minsert\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mplist\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpop\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     21\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mplist\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 22\u001b[1;33m     \u001b[0mplist\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minsert\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mplist\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpop\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     23\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mplist\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     24\u001b[0m     \u001b[0mnew_phrase\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m''\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mplist\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mIndexError\u001b[0m: pop index out of range"
     ]
    }
   ],
   "source": [
    "# 目标:\"Don't panic!\"=>\"on tap\"\n",
    "#利用 列表方法 实现\n",
    "phrase = \"Don't panic!\"\n",
    "plist = list(phrase)# list()\n",
    "print(plist)\n",
    "\n",
    "#删除 D\n",
    "plist.remove('D')\n",
    "print(plist)\n",
    "\n",
    "# 删除末尾4个元素 用pop()删除4次\n",
    "for i in range(4):\n",
    "    plist.pop()\n",
    "    print(plist)\n",
    "    # 删除\"'\"\n",
    "    plist.pop(2)\n",
    "    print(plist)\n",
    "    \n",
    "# plist.extend([plist.pop(),plist.pop()])# 难点在于 执行的运算先后顺序\n",
    "    plist.insert(4,plist.pop())\n",
    "    print(plist)\n",
    "    plist.insert(2,plist.pop(3))\n",
    "    print(plist)\n",
    "    new_phrase = ''.join(plist)\n",
    "    print(new_phrase)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a9b0b2a8",
   "metadata": {},
   "source": [
    "## 2.2列表的实践(课内)     二\n",
    "* 对比实践一  结论:\n",
    "\n",
    ">1.列表的方法 会修改 原本的列表 但是 **列表的切片** 不改变原列表\n",
    "\n",
    ">2.使用列表的方法时,需考虑是否需要先复制列表\n",
    "\n",
    ">3.思考:如何对比代码执行效率?代码执行后的时间 - 代码执行前的时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "id": "8cf53f13",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1637241133.115827"
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "time.time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "id": "e6e9b2c9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n",
      "on tap\n",
      "0.0\n"
     ]
    }
   ],
   "source": [
    "# 目标:\"Don't panic!\"=>\"on tap\"\n",
    "#利用 列表方法 实现\n",
    "实践2运行前时间 = time.time()\n",
    "phrase = \"Don't panic!\"\n",
    "\n",
    "plist = list(phrase)# list():str-->list\n",
    "print(plist)\n",
    "\n",
    "new_phrase = ''.join(plist[1:3])+plist[5]+plist[4]+plist[7]+plist[6]\n",
    "print(new_phrase)\n",
    "实践2运行后时间 = time.time()\n",
    "代码执行时间 = 实践2运行后时间-实践2运行前时间\n",
    "print(代码执行时间)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "41d89f6e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'on tap'"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "''.join(plist[1:3])+plist[5]+plist[4]+plist[7]+plist[6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "id": "da5b8503",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "' tap'"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plist[5]+plist[4]+plist[7]+plist[6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "id": "4d67cfa3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'t'"
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plist[4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "c8869b2b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[' ']"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(plist[5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "31309d73",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "10f3464d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3edecd52",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "eda985ea",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "86a3fb32",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "af294aba",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "06cbccad",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3aa613cf",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "16c2e8f7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8303c7a4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2e8c9ec6",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
